﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Gao.Poker.Domain;
using Gao.Poker.Services;
using Gao.Poker.ViewModel;

namespace Gao.Poker.App.Win
{
    /// <summary>
    /// Interaction logic for RechargeWin.xaml
    /// </summary>
    public partial class RechargeWin : Window
    {
        public MemberMangeViewModel ViewModel { get; set; }

        private Member _member;

        public Member Member
        {
            get { return _member; }
            set
            {
                _member = value;
                DataContext = _member;
            }
        }

        public RechargeWin()
        {
            InitializeComponent();
        }

        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            MemberService ms = new MemberService();
            _member = ms.GetMember(_member.CardNo);
            if (udRechargeMoney.Value != null) _member.ConsumeMoney += udRechargeMoney.Value.Value;
            if (udPoints.Value != null) _member.Points += udPoints.Value.Value;
            ms.Save(_member);

            ViewModel.OnPropertyChanged("Members");
            MessageBox.Show("", "提示信息");
            Close();
        }
    }
}
